﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ThouShaltNotBrick.Models;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
using Microsoft.Xna.Framework.Content.Pipeline;
using ThouShaltNotBrick.PipelineExtension.Readers;

namespace ThouShaltNotBrick.PipelineExtension
{
    [ContentTypeWriter]
    public sealed class CampaignContentTypeWriter : ContentTypeWriter<CampaignData>
    {
        #region Overriden Methods
        protected override void Write(ContentWriter pOutput, CampaignData pValue)
        {
            // NAME (string)
            // NUMBER OF LEVELS (int)
            //   NAME (string)

            pOutput.Write(pValue.Name);

            List<string> levelList = pValue.GetLevels();
            pOutput.Write(levelList.Count);
            foreach (string levelName in levelList)
	        {
                pOutput.Write(levelName);
	        }
        }

        public override string GetRuntimeReader(TargetPlatform pTargetPlatform)
        {
            return typeof(CampaignContentTypeReader).AssemblyQualifiedName;
        }

        public override string GetRuntimeType(TargetPlatform pTargetPlatform)
        {
            return typeof(CampaignData).AssemblyQualifiedName;
        }
        #endregion
    }
}